import routesConfig from '@/routes/config';
import { getConfigRoutes } from './routesConfig';

function getRouteComponents(opts: {
  routes: Record<string, any>;
}) {
  const imports: any = {}
  Object.keys(opts.routes).forEach((key) => {
    const route = opts.routes[key]
    imports[key] = route.file
  })
  return imports;
}

export async function getRoutes() {
  const routes = getConfigRoutes({
    routes: routesConfig,
  })
  const routeComponents = getRouteComponents({
    routes,
  })
  return {
    routes,
    routeComponents
  };
}
